<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Title</title>
</head>
<body>
<script>
    var socket;
    // 判断当前浏览器是否支持webSocket
    if (window.WebSocket) {
        socket = new WebSocket("ws://154.222.22.76:58080/ws")
// 相当于channel的read事件，ev 收到服务器回送的消息
        socket.onmessage = function (ev) {
            var rt = document.getElementById("responseText");
            rt.value = ev.data;
        }
// 相当于连接开启
        socket.onopen = function (ev) {
            var rt = document.getElementById("responseText");
            rt.value = "connect start...."
            socket.send(
                JSON.stringify({
// 连接成功将，用户ID传给服务端
                    clientChannelId: "123476",
                    platformTag: "CMC"
                    // coinType: "BTC"
                })
            );
        }
// 相当于连接关闭
        socket.onclose = function (ev) {
            var rt = document.getElementById("responseText");
            rt.value = rt.value + "\n" + "connect stop...";
        }
    } else {
        alert("not support webSocket")
    }


</script>
<form onsubmit="return false">
    <textarea id="responseText" style="height: 5000px; width: 3000px;"></textarea> <br/>
    <input type="button" value="clear content" onclick="document.getElementById('responseText').value=''">
</form>
</body>
</html>

